<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
                '|one-1<br>',
                '<br>',
                'one-2',
                '<li>item-2</li>',
            '</ol>',
        '</div>',
    ].join(''),
    'insertUnorderedList',
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
            '</ol>',
            '<ul>',
                '<li>|one-1</li>',
            '</ul>',
            '<ol>',
                '<br>',
                'one-2',
                '<li>item-2</li>',
            '</ol>',
        '</div>',
    ].join('')),
    '1 switch list type on text outside LI with BR');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<ul>',
                '<li>one-1</li>',
            '</ul>',
            '<ol>',
                '<br>',
                'one-2',
                '<li>item-2</li>',
                '|two-1',
            '</ol>',
        '</div>',
    ].join(''),
    'insertUnorderedList',
    [
        '<div contenteditable>',
            '<ul>',
                '<li>one-1</li>',
            '</ul>',
            '<ol>',
                '<br>',
                'one-2',
                '<li>item-2</li>',
            '</ol>',
            '<ul>',
                '<li>|two-1</li>',
            '</ul>',
        '</div>',
    ].join('')),
    '2 switch list type on text outside LI');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<ol>',
                '<li>|item-1</li>',
                '<li>item-2</li>',
            '</ol>',
        '</div>',
    ].join(''),
    'insertUnorderedList',
    [
        '<div contenteditable>',
            '<ul>',
                '<li>|item-1</li>',
            '</ul>',
            '<ol>',
                '<li>item-2</li>',
            '</ol>',
        '</div>',
    ].join('')),
    '3 switch list type on text in LI');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
            '</ol>',
            'item-2',
            '<li>|item-3</li>',
        '</div>',
    ].join(''),
    'insertOrderedList',
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
            '</ol>',
            'item-2<br>',
            '<ol>',
                '<li>|item-3</li>',
            '</ol>',
        '</div>',
    ].join('')),
    '4 insertOrderedList on LI outside list');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
            '</ol>',
            'item-2',
            '<li>|item-3</li>',
        '</div>',
    ].join(''),
    'insertUnorderedList',
    [
        '<div contenteditable>',
            '<ol>',
                '<li>item-1</li>',
            '</ol>',
            'item-2<br>',
            '|item-3',  // remove LI
        '</div>',
    ].join('')),
    '5 insertUnorderedList on LI outside list');
</script>
